package java_array;

import java.util.Random;

public class 随机打乱数据 {
    public static void main(String[] args) {
        int arr[] = { 1, 2, 3, 4, 5 };
        Random r = new Random();
        for (int i = 0; i < arr.length; i++) {
            int randomindex = r.nextInt(arr.length);
            int temp = arr[i];
            arr[i] = arr[randomindex];
            arr[randomindex] = temp;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }

}
